package com.jyxd.web.controller.assessment;

import com.jyxd.web.service.assessment.TemperatureReportService;
import com.jyxd.web.util.HttpCode;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Map;

/**
 * 病人最新体温单的数据
 */
@Controller
@RequestMapping(value = "/temperatureReport")
public class TemperatureReportController {

    private static Logger logger= LoggerFactory.getLogger(TemperatureReportController.class);

    @Autowired
    private TemperatureReportService temperatureReportService;

    /**
     * 出入数据或者修改数据
     * @return
     */
    @RequestMapping(value = "/insertAndUpdate")
    @ResponseBody
    public String insert(@RequestBody(required=false) Map<String,Object> map){
        JSONObject json=new JSONObject();
        json.put("code", HttpCode.FAILURE_CODE.getCode());
        json.put("data",new ArrayList<>());
        json.put("msg","添加失败");
        temperatureReportService.insertAndUpdate(map,json);
        return json.toString();
    }

    /**
     * 根据主键id和时间查询
     * @param map
     * @return
     */
    @RequestMapping(value = "/queryData",method= RequestMethod.POST)
    @ResponseBody
    public String queryData(@RequestBody(required=false) Map<String,Object> map){
        JSONObject json=new JSONObject();
        json.put("code",HttpCode.FAILURE_CODE.getCode());
        json.put("data",new ArrayList<>());
        json.put("msg","暂无数据");
        temperatureReportService.queryData(map,json);
        json.put("code",HttpCode.OK_CODE.getCode());
        return json.toString();
    }

}
